// 编辑项目合同

<template>
  <div class="add_wrap">
    <div class="add_from">
      <div class="title">
        基本信息
      </div>

      <!-- 表单 -->
      <el-form ref="form" :model="contractForm" label-width="80px">
        <el-form-item label="合同编号">
          <el-input v-model="contractForm.contractNo"></el-input>
        </el-form-item>
        <el-form-item label="合同名称">
          <el-input v-model="contractForm.contractName"></el-input>
        </el-form-item>
        <el-form-item label="开工日期">
          <el-date-picker type="date" placeholder="选择日期" v-model="contractForm.planBeginDate" style="width: 100%;">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="关联项目">
          <el-select v-model="contractForm.projectId" placeholder="请选择关联项目">
            <el-option v-for="item in relationList" :key="item.id" :value="item.id" :label="item.name">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="甲方名称">
          <el-select v-model="contractForm.jiaFangCompany" placeholder="请选择施工单位">
            <!-- buildTeamList -->
            <el-option v-for="(v,i) in buildTeamList" :key="i" :label="v.nameOfConstructionTeam" :value="v.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="竣工日期">
          <el-date-picker type="date" placeholder="选择日期" v-model="contractForm.planOverDate" style="width: 100%;">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="联系人">
          <el-input v-model="contractForm.jiaFangName"></el-input>
        </el-form-item>
        <el-form-item label="联系电话">
          <el-input v-model="contractForm.jiaFangPhone"></el-input>
        </el-form-item>
        <el-form-item label="项目面积">
          <el-input v-model="contractForm.projectArea"></el-input>
        </el-form-item>
        <el-form-item label="计价方式">
          <el-select v-model="contractForm.valuationId" placeholder="请选择计价方式">
            <el-option v-for="(v,i) in pricingList" :key="i" :label="v.valuation" :value="v.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="付款备注">
          <el-input type="textarea" v-model="contractForm.paymentRemark"></el-input>
        </el-form-item>
        <el-form-item label="是否申请盖章" style="clear:both;">
          <el-switch v-model="contractForm.chapterStatus"></el-switch>
        </el-form-item>
        <el-form-item label="用印类型" style="clear:both;">
          <el-select v-model="contractForm.chapterWithTypeId" placeholder="请选择用印">
            <el-option v-for="(v,i) in printingType" :key="i" :label="v.type" :value="v.id">
            </el-option>
          </el-select>
        </el-form-item>
        <div class="title" style="clear:both;">
          金额信息
        </div>
        <el-form-item label="合同总价">
          <el-input v-model="contractForm.heTongMoney"></el-input>
        </el-form-item>
        <el-form-item label="金额明细" style="clear:both;">
          <template>
            <el-table :data="ExamineData" border style="width: 100%">
              <el-table-column prop="id" label="序号" width="50">
              </el-table-column>
              <el-table-column prop="title" label="子项名称" width="180">
              </el-table-column>
              <el-table-column prop="type" label="合同价">
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button @click="editSubproject(scope.row)" type="text" size="small">编辑</el-button>
                  <el-button @click="delSubproject(scope.row)" type="text" size="small">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-form-item>
        <div class="upload">
          <div class="upload_tit">
            合同附件
          </div>
          <el-form-item label="相关附件">
            <el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/"
              :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="3"
              :on-exceed="handleExceed" :file-list="fileList">
              <el-button size="small" type="primary">+点击上传</el-button>
              <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
            </el-upload>
          </el-form-item>
        </div>
        <el-form-item class="btn">
          <el-button type="primary" @click="keep">保存</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<style src="../BuildTeamContract/style/AddContract.css">
</style>
<script>
import typeMixin from "../../../../minxins/contractMixin/typeMixin";
export default {
  mixins: [typeMixin],
  data () {
    return {

      // 附件列表
      fileList: [
        {
          name: 'food.jpeg',
          url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
        },
        {
          name: 'food2.jpeg',
          url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
        }
      ],
      // 新增项目合同表单
      contractForm: {
        // 合同编号
        contractNo: '',
        // 合同名称
        contractName: '',
        // 开工日期
        planBeginDate: '',
        // 关联项目
        projectId: '',
        // 甲方名称
        jiaFangCompany: '',
        // 竣工日期
        planOverDate: '',
        // 联系人
        jiaFangName: '',
        // 联系电话
        jiaFangPhone: '',
        // 项目面积
        projectArea: '',
        // 计价方式
        valuationId: '',
        // 付款备注
        paymentRemark: '',
        // 是否申请盖章
        chapterStatus: '',
        // 用印类型
        chapterWithTypeId: '',
        // 合同总价
        heTongMoney: '',
        // 附件
        contractEnclosure: '',
        // 创建时间
        createDate: '',
        // 签约时间
        qianYueDate: '',
        // url
        url: '',
        // 合同ID
        contractId: '',
        // 子项目
        ziContractList: [],
        // 子项目名称
        ziHeName: '',
        // 子项目金额
        ziHeTongMoney: ''
      },
      ExamineData: []

    };
  },
  methods: {

    // 附件上传
    handleRemove (file, fileList) {
      console.log(file, fileList);
    },
    handlePreview (file) {
      console.log(file);
    },
    handleExceed (files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove (file) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    // 保存
    keep () {

      // this.$router.push('/contract/buildTeam')
    },
    // --------------------API部分--------------------------------------
    // 编辑子项目
    editSubproject () {

    },
    // 删除子项目
    delSubproject () {

    }
  },
  created () {

  },
  mounted () {
    this.getPrinting()
    this.getRelation()
    this.depSelect()
    this.buildTeamSelect()
    this.staffSelect()
    this.pricingSelect()
  },
  computed: {

  }
};
</script>

<style scoped lang="less">
</style>
